import Vue from 'vue'
const commonComponents = {
  install() {
    const commonFiles = require.context('./', true, /index.vue$/)
    const commonSource = commonFiles
      .keys()
      .reduce((commonSource, modulePath) => {
        const moduleName = modulePath.replace(/^\.\/(.*)\/index\.\w+$/, '$1')
        const value = commonFiles(modulePath)
        commonSource[moduleName] = value.default
        return commonSource
      }, {})
    Object.keys(commonSource).map((e) => {
      Vue.component(commonSource[e].name, commonSource[e])
    })
  },
}
export default commonComponents
